﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Xml;
using System.Xml.Serialization;

namespace RecursosHumanos
{
    public partial class frmFuncionarios : Form
    {
        WBGEntities bd = new WBGEntities();

        public frmFuncionarios()
        {
            InitializeComponent();
        }

        private void frmFilme_Load(object sender, EventArgs e)
        {

            AtualizaGrid();
        }

        private void AtualizaGrid()
        {
            grd.DataSource = from x in bd.Funcionario
                             select new { ID=x.idFuncionario, Nome=x.Pessoa.nome, 
                                          Cargo=x.FuncionarioFuncao.nome,
                                          Ramal=x.ramal, Email=x.email};
            
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void grd_Click(object sender, EventArgs e)
        {
            try
            {
                //grd.CurrentRow.Cells[0].ToolTipText = FilmeGenero.Find(Convert.ToInt32(grd.CurrentRow.Cells["genero"].Value.ToString()));
            }
            catch { }
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            var frm = new frmPessoa(Request.Inserir, Entidade.Funcionario);
            frm.ShowDialog();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(grd.CurrentRow.Cells["ID"].Value);
            var frm = new frmPessoa(Request.Alterar, Entidade.Funcionario);
            frm.funcionario = bd.Funcionario.FirstOrDefault(x => x.idFuncionario == id);
            frm.ShowDialog();
            AtualizaGrid();
        }
    }
}
